﻿using AutoMapper;
using Common.Domain;
using Common.Infrastructure.Repository;
using Common.Services;
using MediatR;

namespace Business.ReadAPI.Application.Machinings
{
    /// <summary>
    /// 辅料信息
    /// </summary>
    public class AccessoriesQueryRequestHandler : IRequestHandler<AccessoriesQueryRequestModel, APIResult>
    {
        private IBaseRepository<Accessories> baseRepository;
        private readonly IMapper mapper;
        public AccessoriesQueryRequestHandler(IBaseRepository<Accessories> baseRepository, IMapper mapper)
        {
            this.baseRepository = baseRepository;
            this.mapper = mapper;
        }
        public Task<APIResult> Handle(AccessoriesQueryRequestModel request, CancellationToken cancellationToken)
        {
            APIResult result = new APIResult();
            result.Code = EnumCode.SearchSuccess;
            result.Msg = "查询成功";

            var list = baseRepository.GetAll().FirstOrDefault();
            result.Data = list;

            return Task.FromResult(result);
        }
    }
    public class AccessoriesQueryRequestModel:IRequest<APIResult>
    { 
    }
    public class AccessoriesQueryResponseModel
    {
    public int Id { get; set; }
    public string ProductCode { get; set; }
    public string ProductionBatch { get; set; }//生产批次
    public string Creator { get; set; }
    public DateTime CreateTime { get; set; }
}
}
